﻿/// <Reference Name="MicrosoftAjax.js" />

function pageLoad(sender, args) {

    // Load required file before execute other operations
    Sys.require([Sys.scripts.UI, Sys.scripts.Data], function () {
        Sys.UI.DomEvent.addHandler($get('AddTicket'), 'click', addNewTicket);
    });
}


function addNewTicket(evt) {


    if (!Page_ClientValidate()) return;

    var ticket = new Object();
    ticket['Title'] = Toolkit.UI.selectValue('TicketTitle');
    ticket['TicketPriority'] = Toolkit.UI.selectValue('TicketPriority');
    ticket['Des'] = Toolkit.UI.selectValue('TicketDescription');

    Toolkit.Data.addItem(ticket, 'Support Tickets', function (item) {
        SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK);
    });



}


